import request from "@/api/request";
export default {
    questionList:(param,token)=>{
      return request({
          url:'/problem/list',
          method:'post',
          headers: {'token': token},
          data:param
      })
    },
    questionDetail:(param,token)=>{
        return request({
            url:'/problem/detail',
            method:'post',
            headers: {'token': token},
            data:param
        })
    },
    questionSubmit:(param,token)=>{
        return request({
            url: 'submission/create',
            method:'post',
            headers: {'token': token},
            data:param
        })
    },
    getSubmissionResult:(param,token)=> {
        return request({
            url: 'submission/getLatestResult',
            method:'post',
            headers: {'token': token},
            data:param
        })
    },
    questionCategoryList:(token)=>{
        return request({
            url:'/category/list',
            method:'get',
            headers: {'token': token},
        })
    },
    // getLatestSubmissions:(param,token)=>{
    //     return request({
    //         url: 'submission/getLatestSubmissions',
    //         method:'post',
    //         headers: {'token': token},
    //         data:param
    //     })
    // },
    getCategories:(token)=>{
      return request({
          url: '/category/list',
          method:'get',
          headers: {'token': token},
      })
    },
    getTags:(token)=>{
        return request({
            url: '/tag/list',
            method:'get',
            headers: {'token': token},
        })
    },
    //代码信息临时保存
    tmpSave:(params,token)=>{
        return request({
            url:'/train/train-user-commit/tmp-save',
            method:'get',
            headers: {'token': token},
            params:{
                id:params.id,
                classId: params.classId,
                problemId: params.problemId,
                language: params.language,
                answer: params.answer,
                homeworkId: params.homeworkId,
            }
        })
    },
    //获取临时存储代码信息
    getTmpSave:(params,token)=>{
        return request({
            url:'/train/train-user-commit/get-tmp-save',
            method:'get',
            headers: {'token': token},
            params:{
                classId: params.classId,
                problemId: params.problemId,
                language: params.language,
                homeworkId: params.homeworkId,
            }
        })
    },

    submitCode:(param,token)=> {
        return request({
            url: '/train/train-user-commit/submit',
            method:'post',
            headers: {'token': token},
            data:param
        })
    },
    viewRecord:(param,token)=> {
        return request({
            url: '/train/train-user-commit/record',
            method:'get',
            headers: {'token': token},
            params:{
                classId: param.classId,
                problemId: param.problemId,
                homeworkId: param.homeworkId,
            }
        })
    },

    getSubmitStatus:(param,token)=> {
        return request({
            url: '/train/train-user-commit/submit',
            method:'post',
            headers: {'token': token},
            params:{
                submitId:param.submitId
            }
        })
    },
    getLatestSubmissions:(param,token)=> {
        return request({
            url: '/submission/getLatestSubmissions',
            method:'post',
            headers: {'token': token},
            data:param
        })
    },

}